package com.sharepics.utils.bean;

import org.apache.commons.codec.binary.Base64;

import com.sharepics.bean.Album;
import com.sharepics.bean.Picture;
import com.sharepics.bean.XMLAlbum;
import com.sharepics.bean.XMLPicture;

public class BeanUtils {

	public static Album get(XMLAlbum xmlAlbum){
		Album a = new Album();
		a.name = xmlAlbum.getName();
		a.remoteId = xmlAlbum.getId();
		return a;
	}
	
	public static XMLAlbum get(Album album){
		XMLAlbum xmlAlbum = new XMLAlbum();
		xmlAlbum.setId(album.id);
		xmlAlbum.setName(album.name);
		return xmlAlbum;
	}
	
	
	public static XMLPicture get(Picture pic,byte[] data){
		XMLPicture xmlPic = new XMLPicture();
		xmlPic.setId(pic.id);
		xmlPic.setName(pic.name);
		xmlPic.setLatitude(pic.latitude);
		xmlPic.setLongitude(pic.longitude);
		xmlPic.setContentType(pic.getContentType());
		Base64 base64 = new Base64();
		String bytes64 = base64.encodeToString(data);
		xmlPic.setBytes(bytes64);
		xmlPic.setDate(pic.getDate());
		return xmlPic;
	}
}
